#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <vector>

#include <QMainWindow>
#include <QTableWidget>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QDebug>

#include "person.h"
#include "sqlite_helper.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void InitializeUi();

private slots:
    void on_connect_btn_clicked();

    void on_refresh_btn_clicked();

    void on_add_btn_clicked();

    void on_update_btn_clicked();

private:
    enum class CellType : int {
        kId = 100,
        kName,
        kAge,
    };

    enum class FieldColumnNumber : int {
        kId = 0,
        kName,
        kAge,
    };

    void SetItem2TableWidget(QTableWidget *const table, const int row_number, const QString &text, const CellType &cell_type,
                             const FieldColumnNumber &field_column_number);
    void SetItem2TableWidget(QTableWidget *const table, const int row_number, const QString &text, const CellType &cell_type,
                             const FieldColumnNumber &field_column_number, Qt::Alignment alignment);
    void RefreshTable(QTableWidget *const table);
    Ui::MainWindow *ui;
    SqliteHelper sqlite_helper;
};
#endif // MAINWINDOW_H
